package flc.ast.adapter;

import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.text.SimpleDateFormat;
import java.util.List;

import flc.ast.R;
import flc.ast.bean.MyCollectBean;
import flc.ast.bean.MyVideoBean;
import flc.ast.utils.AppSpUtils;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.basic.utils.TimeUtil;

public class VideoAdapter extends StkProviderMultiAdapter<MyVideoBean> {

    public VideoAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(100));
        addItemProvider(new VideoProvider());
    }

    private boolean isEdit = false;
    private boolean isSel=false;

    public void setSel(boolean sel) {
        isSel = sel;
    }

    public void setEdit(boolean edit) {
        isEdit = edit;
    }

    private String text = "";

    public void setText(String text) {
        this.text = text;
    }

    private class VideoProvider extends BaseItemProvider<MyVideoBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_video;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyVideoBean bean) {
            Glide.with(getContext()).load(bean.getPath()).into((ImageView) baseViewHolder.getView(R.id.ivVideoItemImg));
            baseViewHolder.setText(R.id.tvVideoItemName,bean.getName());
            baseViewHolder.setText(R.id.tvVideoItemDate, TimeUtils.millis2String(FileUtils.getFileLastModified(bean.getPath()), new SimpleDateFormat("yyyy-MM-dd")));
            baseViewHolder.setText(R.id.tvVideoItemLength, TimeUtil.getHHmmss(bean.getLength()));
            if (bean.isCollect()){
                baseViewHolder.setImageResource(R.id.ivVideoItemCollect,R.drawable.ysc1);
            }else {
                baseViewHolder.setImageResource(R.id.ivVideoItemCollect,R.drawable.wsc1);
            }
        }
    }
}
